@extends('admin.main')
@section('content')
    <div class="daohang">
        <ul>
            <li>
                <button type="button" class="am-btn am-btn-default am-radius am-btn-xs">医师管理></button>
            </li>
            <li>
                <button type="button" class="am-btn am-btn-default am-radius am-btn-xs">编辑医师
                </button>
            </li>
        </ul>
    </div>
    <div class="admin-biaogelist">
        <div class="listbiaoti am-cf">
            <ul class="am-icon-flag on"> 编辑医师</ul>
        </div>

        <div class="fbneirong">
            <form class="am-form" method="post">
                <div class="am-form-group am-cf">
                    <div class="zuo">上传头像：</div>
                    <div class="you">
                        <img id="pic" src="/{{$data['avatar']}}" style="width: 80px;height: 80px" alt="">
                        <input type="hidden" id="avatar" name="avatar">
                        <input style="width: 150px;" type="file" id="uploadImage" accept="image/*" num="1"
                               onchange="upload(this,'imgs','btns','thumb')"/>

                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">医师姓名：</div>
                    <div class="you" style="width:200px">
                        <input name="name" type="text" class="am-input-sm" placeholder="请输入医师姓名"
                               value="{{$data['name']}}">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">职务：</div>
                    <div class="you" style="width:200px">
                        <input name="job" type="text" class="am-input-sm" placeholder=" 如: 主任/副主任"
                               value="{{$data['job']}}">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">职称：</div>
                    <div class="you" style="width:200px">
                        <input name="pro_title" type="text" class="am-input-sm"
                               placeholder="如: 教授/副教授" value="{{$data['pro_title']}}">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">专家标识：</div>
                    <div class="you" style="width:200px">
                        <input name="pro_tag" type="text" class="am-input-sm" placeholder="如: 儿童专家；成人专家可不填"
                               value="{{$data['pro_tag']}}">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">所属科室描述：</div>
                    <div class="you" style="width:200px">
                        <input name="depart_desc" type="text" class="am-input-sm"
                               placeholder="如: 口腔科专家/耳鼻喉专家" value="{{$data['depart_desc']}}">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">个性签名：</div>
                    <div class="you">
                        <textarea name="self_sign" class="" rows="2"
                                  placeholder=" 如: 50个字,省着写">{{$data['self_sign']}}</textarea>
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">从业经验：</div>
                    <div class="you" style="width:200px">
                        <input name="work_exp" type="text" class="am-input-sm" placeholder="如: 30年经验"
                               value="{{$data['work_exp']}}">
                    </div>
                </div>

                <div class="am-form-group am-cf">
                    <div class="zuo">科室分类：</div>
                    <div class="you">
                        <select name="depart_id" id="depart_id" style="width:200px;height:30px;font-size: 11px;"
                                class="chosen-select" tabindex="7" onchange="apidoc(this.value)">
                            @if($departs)
                                @foreach($departs as $v)
                                    <option @if($data['depart_id'] == $v['id']) selected
                                            @endif value="{{$v['id']}}">{{$v['name']}}</option>
                                @endforeach
                            @endif
                        </select>
                    </div>
                </div>


                <div class="am-form-group am-cf">
                    <div class="zuo">原所在单位：</div>
                    <div class="you">
                        <input name="origin_company" type="text" class="am-input-sm"
                               placeholder="请输入原所在单位" value="{{$data['origin_company']}}">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">技术专长：</div>
                    <div class="you">
                        <textarea name="tech_desc" class="" rows="2"
                                  placeholder="请输入技术专长">{{$data['tech_desc']}}</textarea>
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">名医简介：</div>
                    <div class="you">
                        <textarea name="intro" class="" rows="2" placeholder="请输入名医简介">{{$data['intro']}}</textarea>
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">咨询价格：</div>
                    <div class="you" style="width:100px">
                        <input name="advice_price" type="text" class="am-input-sm"
                               placeholder="请输入咨询价格" value="{{$data['advice_price']}}">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">咨询时长(分钟)：</div>
                    <div class="you" style="width:100px">
                        <input name="advice_time" type="text" class="am-input-sm"
                               placeholder="请输入咨询时长" value="{{$data['advice_time']}}">
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">客服咨询绑定：</div>
                    <div class="you" style="width:100px">
                        <select name="customer_service" id="reffer_ke" style="width:150px;height:30px;font-size: 11px;" class="chosen-select" tabindex="7">
                            @if(isset($kefu))
                                @foreach($kefu as $v)
                                    <option value="{{$v['id']}}" @if($data['customer_service'] == $v['id']) selected
                                            @endif }}>{{$v['realname']}}</option>
                                @endforeach
                            @endif
                        </select>
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">咨询价格：</div>
                    <div class="you" style="width:100px">
                        <input name="advice_price" type="text" class="am-input-sm"
                               placeholder="请输入咨询价格" value="{{$data['advice_price']}}">
                    </div>
                </div>

                <div class="am-form-group am-cf">
                    <div class="zuo">平台医生和his医生的关联:</div>
                    <div class="you" style="width:200px">
                        <select name="reffer_id" id="reffer_id" style="width:150px;height:30px;font-size: 11px;"
                                class="chosen-select" tabindex="7">
                            @if($doctors)
                                @if(isset($doctors[0]))
                                    @foreach($doctors as $v)
                                        <option @if($data['reffer_id'] == $v['BCE01']) selected
                                                @endif value="{{$v['BCE01']}}">{{$v['BCE03']}}</option>
                                    @endforeach
                                @else
                                    <option @if($data['reffer_id'] == $doctors['BCE01']) selected
                                            @endif value="{{$doctors['BCE01']}}">{{$doctors['BCE03']}}</option>
                                @endif
                            @endif
                        </select>
                    </div>
                </div>
                <div class="am-form-group am-cf">
                    <div class="zuo">平台医生挂号类别:</div>
                    <div class="you" style="width: 200px;">
                        <select name="reg_type" id="reg_type" style="width:200px;height:30px;font-size: 11px;"
                                class="chosen-select" tabindex="7">
                            @if($types)
                                @foreach($types as $v)
                                    <option @if($data['reg_type'] == $v['号类ID']) selected
                                            @endif value="{{$v['号类ID']}}">{{$v['号类名称']}}</option>
                                @endforeach
                            @endif
                        </select>
                    </div>
                </div>

                <div class="am-form-group am-cf">
                    <div class="zuo">平台医生挂号类别(VIP):</div>
                    <div class="you" style="width: 200px;">
                        <select name="reg_type_vip" id="reg_type_vip" style="width:200px;height:30px;font-size: 11px;"
                                class="chosen-select" tabindex="7">
                            @if($types)
                                @foreach($types as $v)
                                    <option @if($data['reg_type_vip'] == $v['号类ID']) selected
                                            @endif value="{{$v['号类ID']}}">{{$v['号类名称']}}</option>
                                @endforeach
                            @endif
                        </select>
                    </div>
                </div>

                <div class="am-form-group am-cf">
                    <div class="you" style="margin-left: 11%;">
                        <center>
                            <input type="hidden" name="id" value="{{$data['id']}}">
                            <button type="submit" class="am-btn am-btn-success am-radius">保存并提交</button>
                        </center>
                    </div>
                </div>


            </form>
        </div>
    </div>
@section('script')
    <script>
        var message = "{{Session::get('message')}}";
        $(window).ready(function () {
            if (message) {
                layer.msg(message, {
                    time: 3000 //2秒关闭（如果不配置，默认是3秒）
                });
            }
        });
        function upload(obj) {
            var _self = obj;
            var _this = $(obj);
            var fileReader = new FileReader();
            fileReader.onload = function (e) {
                if (fileReader.readyState == FileReader.DONE) {
                    $("#pic").attr('src', this.result);
                    $("#avatar").val(this.result);
                }
            };
            //一次加载多个文件
            var i = 0, src = _self.files;
            fileReader.readAsDataURL(src[i]);
            fileReader.onloadend = function () {
                i++;
                if (i < src.length) fileReader.readAsDataURL(src[i]);
            }
        }

        function apidoc(id) {
            var url = "{{urlAdmin('doctor','getAjaxDoctors')}}?depart_id=" + id;
            $.get(url, function (res) {
                var $select = $('#reffer_id');
                $select.empty();
                var str = '';
                if (res.length > 0) {
                    for (var i = 0; i < res.length; i++) {
                        str += '<option value="' + res[i].BCE01 + '">' + res[i].BCE03 + '</option>';
                    }
                } else {
                    str += '<option value="' + res.BCE01 + '">' + res.BCE03 + '</option>';
                }
                $select.append(str);
                $select.trigger('chosen:updated');
            });
        }
    </script>
@endsection
@include('admin.footer')
@endsection